/*************************************************************************
    Projet  -  Sport Collectif pour Robots
                             -------------------
    Auteur  -  Loic Thouvenin
*************************************************************************/

#ifndef UTIL_H_
#define UTIL_H_


//------------------------------------------------------------------------
// Role de l'interface <util>
//
//------------------------------------------------------------------------


//--------------------------------------------------- Interfaces utilisees

#ifdef __APPLE__	// mac
#include <opencv/openCV.h>
#endif

#ifdef __linux__	// gcc (egcs) on linux
#include <opencv.hpp>
#endif

#include "config.h"
#include "sys/time.h"

using namespace scor;
using namespace cv;


//----------------------------------------------------------------- PUBLIC

template<typename T> struct val_st
{
	T* pThis;
	void (T::*pFunc)();
};

template<typename T> void* pThreadWrapper(void* dat_s)
{
        struct val_st<T>* v = static_cast<val_st<T>*>(dat_s);
        T* pThis = v->pThis;
        void ((T::*pFunc)()) = v->pFunc;
        //Launch method
        (pThis->*pFunc)();
        return NULL;
}

//---------------------------------------------------- Fonctions publiques

long squareDistance(CvPoint *point0, CvPoint *point1);

bool calculerVitesse(const Position & prevPos, const Position & lastPos, Vec2d & vitesse);

/* ##### Add by Matuchifra ##### */
long computeTimeStamp();
double norme(const Vec2d & v);



#endif /* UTIL_H_ */
